/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package l2.jw.scripts.teleports;
import l2.jw.gameserver.model.actor.L2Npc;
import l2.jw.gameserver.model.actor.instance.L2PcInstance;
import l2.jw.gameserver.model.quest.Quest;
import l2.jw.gameserver.model.quest.QuestState;
/**
 * Angel l2.jw World  http://jumpworld.org.ua/
 */
public class DelusionTeleport extends Quest
{
	private final static int REWARDER_ONE = 32658;
	private final static int REWARDER_TWO = 32659;
	private final static int REWARDER_THREE = 32660;
	private final static int REWARDER_FOUR = 32661;
	private final static int REWARDER_FIVE = 32663;
	private final static int REWARDER_SIX = 32662;
	private final static int START_NPC = 32484;
	private static int _x;
	private static int _y;
	private static int _z;

	public DelusionTeleport(int questId, String name, String descr)
	{
		super(questId, name, descr);
		addStartNpc(START_NPC);
		addTalkId(START_NPC);
		addTalkId(REWARDER_ONE);
		addTalkId(REWARDER_TWO);
		addTalkId(REWARDER_THREE);
		addTalkId(REWARDER_FOUR);
		addTalkId(REWARDER_FIVE);
		addTalkId(REWARDER_SIX);
	}

	@Override
	public String onTalk(L2Npc npc, L2PcInstance player)
	{		
		switch (npc.getNpcId())
		{
			case START_NPC:
				_x = player.getX();  
				_y = player.getY();
				_z = player.getZ();
				player.teleToLocation(-114592, -152509, -6723);
				if (player.getPet() != null)
					player.getPet().teleToLocation(-114592, -152509, -6723);	
				break;
			case REWARDER_ONE:
			case REWARDER_TWO:
			case REWARDER_THREE:
			case REWARDER_FOUR:
			case REWARDER_FIVE:
			case REWARDER_SIX:
				final QuestState st = player.getQuestState(getName());
				if (st == null)
					break;
				
				player.teleToLocation(_x, _y, _z);
				if (player.getPet() != null)
					player.getPet().teleToLocation(_x, _y, _z);					
				st.exitQuest(true);
				break;
		}

		return null;
	}
	
	public static void main(String[] args)
	{
		new DelusionTeleport(-1, "DelusionTeleport", "teleports");
	}
}